# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=opentracker
pkgver=0_git20180526
pkgrel=1
pkgdesc="an open and free bittorrent tracker"
url="http://erdgeist.org/arts/software/opentracker/"
arch="all"
license="GPL"
makedepends="libowfat-dev zlib-dev"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc ${pkgname}6"
source="https://dev.alpinelinux.org/opentracker/opentracker-$pkgver.tar.gz
	opentracker.initd"

builddir="$srcdir"/$pkgname

prepare() {
	cp -r "$builddir" "$builddir"6
}

build() {
	cd "$builddir"
	PREFIX=/usr/include make
	cd "$builddir"6
	make PREFIX=/usr/include FEATURES=-DWANT_V6 BINARY=opentracker6
}

package() {
	cd "$builddir"
	install -d "$pkgdir"/usr/bin
	install -m755 "$builddir"6/opentracker6 "$pkgdir"/usr/bin/opentracker6
	make BINDIR="$pkgdir"/usr/bin install
	install -m644 -D opentracker.conf.sample \
		"$pkgdir"/etc/opentracker/opentracker.conf
	install -m755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	ln -s opentracker "$pkgdir"/etc/init.d/opentracker6
}

opentracker6() {
	pkgdesc="IPv6 version of opentracker"
	install -d "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/opentracker6 "$subpkgdir"/usr/bin/
}

sha512sums="44a9e07b304a9e0fc7e087ad0b80b24464ffecfbe77a50518ca29178026664773188900b0ced4f382d98620c5ad4ff5687b5f6421994170bfd5fc1f78979fd2f  opentracker-0_git20180526.tar.gz
ec998cc5a80089f2cbeeafa9a558aa0713a698508f4511e68079046e21c35727f4b4667fb9ccbdf0bf293e989839d5678c5602c12a905f6c1d5037d5b543316f  opentracker.initd"
